import Log4R from "shared/component/log/Log4R";
import characterTools from "shared/component/common/characterTools";

import { aninmClient, camera2DClient, characterClient, characterStateClient, dashboardClient, effectClient, move2DClient, physical2DClient, SkillClient, soundClient } from "./clientLib";
const loinfo = Log4R.getLog('info')
/** 角色服务 */


/* 角色模型更新 */
characterClient?.onCharacterAdd((characterEntiy) => {

    const character = characterEntiy.character;
    if (!character) throw ('no character')
    camera2DClient.bindPlayerCharacter(character);//绑定角色视角
    physical2DClient.constraint(character.HumanoidRootPart, characterTools.getRootAttName())//绑定2D物理
    characterStateClient.addCharacter(characterEntiy)//监听角色状态
    move2DClient.addCharacter({
        humanModel: character,
    })//绑定角色运动控制
    loinfo?.info('dashboardClient.showStartButton')
    dashboardClient.showStartButton();//显示开始画面
    SkillClient.addCharacter(character)
    aninmClient.addCharacter(characterEntiy);//添加角色动画
    effectClient.addCharacter(characterEntiy);//添加特效
    soundClient.addCharacter(characterEntiy)
})
export default characterClient